# coding=utf-8
"""
权限模块
"""
from functools import wraps
from flask import abort
from flask_login import current_user, login_required


def admin_required(f):
    @wraps(f)
    @login_required
    def decorated_function(*args, **kwargs):
        if current_user.role != current_user.ROLES['admin']:
            abort(403)
        return f(*args, **kwargs)
    return decorated_function
